#!/bin/sh -eu

# Check for mistakes in tarball distribution

# Make sure we don't distribute gz files
find $1/dist -name '*.gz' -print | tee /dev/stderr | sort | while read file; do
        echo "Refusing to distribute gzip files" >&2
        exit 1
done

# Make sure all po files are valid
find $1/po -name '*.po' -print | while read file; do
    if ! msgfmt "$file" -o /dev/null; then
        echo "Refusing to distribute invalid po file: $file" >&2
        exit 1
    fi
done

# Validate our AppStream metadata
find $1 -name '*.metainfo.xml' -o -name '*.appdata.xml' | xargs appstream-util validate
